package zengqiang.接口回调;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Frame2 extends Frame {
    private TextField tf=new TextField(20);
    private Button button=new Button("PayMnet");
    public Frame2() {
        this.setSize(600, 400);
        this.setTitle("Frame2");
        this.setLayout(new FlowLayout());
        this.add(tf);
        this.add(button);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String text = tf.getText();
                moneyListener.setMoney(text);
            }
        });
        this.setVisible(true);
    }
    private MoneyListener moneyListener;
    public void setMoneyListener(MoneyListener moneyListener){
            this.moneyListener=moneyListener;
    }

    interface MoneyListener{
        void setMoney(String money);
    }
}
